import 'package:banyou_app/app/config/colors.dart';
import 'package:banyou_app/app/widget/mang_widget.dart';
import 'package:banyou_app/app/widget/picture_overview_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';

final box = GetStorage();

final channel = MethodChannel("methodChannel");

//复制
Future copyText(text) {
  return Clipboard.setData(ClipboardData(text: text));
}
// 忙
Future showMang(String title) {
  return Get.dialog(MangDialogView(title),
      barrierColor: Colors.black.withAlpha(100));
}
// 
showImgs(imgs, index) {
  Get.dialog(
    PictureOverview(imageItems: imgs, defaultIndex: index),
    barrierColor: Colors.black.withAlpha(100),
    useSafeArea: false,
  );
}



Future MshowDialog(String title,
    {String confirmtitle = "确定", String cancelTitle = '取消'}) {
  return Get.dialog(
    AlertDialog(
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(5))),
      clipBehavior: Clip.none,
      contentPadding: EdgeInsets.zero,
      backgroundColor: Colors.transparent,
      elevation: 0,
      content: Container(
        // height: 152,
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(5))),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              // height: 105,
              padding: EdgeInsets.symmetric(vertical: 30, horizontal: 15),
              alignment: Alignment.center,
              child: Text(
                title,
                textAlign: TextAlign.center,
                style: TextStyle(
                    fontSize: 16.sp,
                    color: ColorConfig.text_label,
                    fontWeight: FontWeight.w500),
              ),
            ),
            Container(
              width: 1.sw,
              height: .5,
              color: Color(0xFFDDDDDD),
            ),
            Container(
                height: 45,
                child: Row(
                  children: [
                    Expanded(
                      child: InkWell(
                        onTap: () {
                          Get.back(result: 0);
                        },
                        child: Center(
                          child: Text(cancelTitle,
                              style: TextStyle(
                                  color: Color(0xFF999999),
                                  fontFamily: 'mononoki',
                                  fontSize: 16.sp)),
                        ),
                      ),
                    ),
                    Container(
                      width: .5,
                      height: 45,
                      color: Color(0xFFDDDDDD),
                    ),
                    Expanded(
                        child: InkWell(
                      onTap: () {
                        Get.back(result: 1);
                      },
                      child: Center(
                        child: Text(confirmtitle,
                            style: TextStyle(
                                color: ColorConfig.app_main,
                                fontFamily: 'mononoki',
                                fontSize: 16.sp)),
                      ),
                    )),
                  ],
                )),
          ],
        ),
      ),
    ),
    barrierColor: Colors.black.withAlpha(20),
  );
}
